package com.swj.modules.system.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.swj.common.core.model.SysOperaLog;
import com.swj.common.core.model.web.RestResult;
import com.swj.common.core.utils.ResponseUtil;
import com.swj.common.security.annotation.RequiresPermissions;
import com.swj.modules.system.model.SysOperaLogQueryVO;
import com.swj.modules.system.service.ISysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 操作日志记录
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/operlog")
public class SysOperlogController {

    @Autowired
    private ISysOperLogService operLogService;

//    @RequiresPermissions("system:operlog:list")
//    @GetMapping("/list")
//    public TableDataInfo list(SysOperaLog operLog)
//    {
//        startPage();
//        List<SysOperaLog> list = operLogService.selectOperLogList(operLog);
//        return getDataTable(list);
//    }


    @RequiresPermissions("system:operlog:list")
    @GetMapping("/page")
    public RestResult list(SysOperaLogQueryVO operaLog) {
        Page<SysOperaLog> page = operLogService.selectOperLogPage(operaLog);
        return ResponseUtil.successWithPageList(page);
    }
//
//    @Log(title = "操作日志", businessType = BusinessType.EXPORT)
//    @RequiresPermissions("system:operlog:export")
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, SysOperaLog operLog)
//    {
//        List<SysOperaLog> list = operLogService.selectOperLogList(operLog);
//        ExcelUtil<SysOperaLog> util = new ExcelUtil<SysOperaLog>(SysOperaLog.class);
//        util.exportExcel(response, list, "操作日志");
//    }
//
//    @Log(title = "操作日志", businessType = BusinessType.DELETE)
//    @RequiresPermissions("system:operlog:remove")
//    @DeleteMapping("/{operIds}")
//    public AjaxResult remove(@PathVariable Long[] operIds)
//    {
//        return toAjax(operLogService.deleteOperLogByIds(operIds));
//    }
//
//    @RequiresPermissions("system:operlog:remove")
//    @Log(title = "操作日志", businessType = BusinessType.CLEAN)
//    @DeleteMapping("/clean")
//    public AjaxResult clean()
//    {
//        operLogService.cleanOperLog();
//        return success();
//    }

    //@InnerAuth
    @PostMapping("/add")
    public RestResult add(@RequestBody SysOperaLog operLog) {
        operLogService.save(operLog);
        return ResponseUtil.success("ok");
    }
}
